<template>
	<view class="btn-box">
		<button v-if="showBtnConfirm" @tap.stop="onConfirm(orderId)" class="cu-btn obtn2">填写物流单号</button>
		<button v-if="showBtnCancel" @tap.stop="onCancel(orderId)" class="cu-btn obtn1">撤销申请</button>
	</view>
</template>
<script>
// 订单交易完成可申请售后 退款/售后订单
// - 仅退款
//     - CLOSED(退款关闭，未审核前，买家主动取消)
//     - WAIT_SELLER_AGREE(买家已经申请退款，等待卖家同意)   默认48小时未审核则自动退款
//     - SELLER_REFUSE_BUYER(卖家拒绝退款)
//     - SUCCESS(退款成功)
// - 退款并退货
//     - CLOSED(退款关闭，未审核前，买家主动取消)
//     - WAIT_SELLER_AGREE(买家已经申请退款，等待卖家同意)         默认48小时未审核则自动确认
//     - WAIT_BUYER_RETURN_GOODS(卖家已经同意退款，等待买家退货)
//     - WAIT_SELLER_CONFIRM_GOODS(买家已经退货，等待卖家确认收货) 默认自动收货时间15天
//     - SELLER_REFUSE_BUYER(卖家拒绝退款)
//     - SUCCESS(退款成功)
export default {
	props: {
		orderStatus: {
			type: String,
			required: true
		},
		orderId: {
			type: Number,
			required: true
		}
	},
	computed: {
		showBtnCancel: function () {
			return this.orderStatus === 'WAIT_SELLER_AGREE' || 
					this.orderStatus === 'WAIT_BUYER_RETURN_GOODS'
		},
		showBtnConfirm: function () {
			return this.orderStatus === 'WAIT_BUYER_RETURN_GOODS'
		},
		
	},
	methods: {
		// 取消订单
		onCancel(orderId) {
			let that = this;
			that.$api('refund.cancel', {
				refund_id: orderId
			}).then(res => {
				if (res.code === 1) {
					that.$Router.back();
				}
			});
		},
		// 填写物流单号
		onConfirm(orderId) {
			let that = this;
			uni.showModal({
				title:'请填写物流单号',
				content:'请填写物流单号',
				showCancel:true,
				success: function (res) {
					if (res.confirm) {
						console.log('用户点击确定');
						// that.$api('order.confirm', {
						// 	orderId: orderId
						// }).then(res => {
						// 	if (res.code === 1) {
						// 		setTimeout(()=>{
						// 			uni.redirectTo({
						// 				url: this.$route.fullPath
						// 			});
						// 		},1000)
						// 	}
						// });
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			})
			
		}
	}
};
</script>
<style lang="scss">
.btn-box {
		justify-content: flex-end;
		// margin-bottom: 20rpx;
		.obtn1 {
			width: 160rpx;
			height: 60rpx;
			background: rgba(238, 238, 238, 1);
			border-radius: 30rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: rgba(51, 51, 51, 1);
			margin-right: 20rpx;
			padding: 0;
		}
		.obtn2 {
			width: 160rpx;
			height: 60rpx;
			background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
			box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
			border-radius: 30rpx;
			margin-right: 20rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: rgba(168, 112, 13, 0.9);
			padding: 0;
		}
	}
</style>
